home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / DOS.SWG / 0037_FLUSHDOS.PAS.pas < prev    next >
Pascal/Delphi Source File  |  1993-11-21  |  1KB  |  59 lines

  1. PROGRAM FlushDem;
  2.  
  3.   FUNCTION DosFlush(VAR F) : BOOLEAN; Assembler;
  4.   ASM
  5.     MOV AX, 3000h       {get DOS version}
  6.     INT 21h
  7.     CMP AL, 3           {DOS < 3? old!}
  8.     JL @old
  9.     CMP AH, 1Eh         {DOS < 3.3? old!}
  10.     LES DI, F
  11.     MOV BX, ES:[DI]     {file handle is first word}
  12.     MOV AH, 68h         {commit file function}
  13.     INT 21h
  14.     JC @BadEnd
  15.     JMP @GoodEnd
  16.  
  17.     @old:
  18.     LES DI, F
  19.     MOV BX, ES:[DI]     {file handle is first word}
  20.     MOV AH, 45h         {duplicate handle function}
  21.     INT 21h
  22.     JC @BadEnd
  23.     @ok:
  24.     MOV BX, AX          {put duped handle in BX...}
  25.     MOV AH, 3Eh         {... and close it}
  26.     INT 21h
  27.     JC @BadEnd
  28.     @GoodEnd:
  29.     MOV AX, 0
  30.     @BadEnd:
  31.   END;
  32.  
  33. VAR
  34.   T1, T2 : Text;
  35.   S      : String;
  36.   W      : Word;
  37. BEGIN
  38.   Assign(T1, 'DEMO1.$$$');
  39.   Rewrite(T1);
  40.   Assign(T2, 'DEMO2.$$$');
  41.   Rewrite(T2);
  42.   S := 'This is just a sample line of text.';
  43.   FOR W := 1 to 100 DO
  44.     BEGIN
  45.       WriteLn(T1, W:4, ' ', S);
  46.       WriteLn(T2, W:4, ' ', S);
  47.     END;
  48.   IF DosFlush(T2) THEN
  49.     BEGIN
  50.       WriteLn('Successfully flushed the second demo ',
  51.               'file.  Please reboot your computer.');
  52.       ReadLn;
  53.       WriteLn('Hey, I said PLEASE reboot.  Oh well... ',
  54.               ' I will erase the temporary files.');
  55.       Close(T1);  Erase(T1);
  56.       Close(T2);  Erase(T2);
  57.     END
  58.   ELSE WriteLn('DosFlush routine failed.');
  59. END.